package com.ncs.base.task.quartz;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.ncs.base.task.entity.UserMasterEntity;
import com.ncs.base.task.service.OrderSequenceMasterService;
import com.ncs.base.task.service.OrderSequenceSalveService;
import com.ncs.base.task.service.UserMasterService;
import com.ncs.base.task.service.UserSalveService;

import lombok.extern.slf4j.Slf4j;

@EnableAsync
@Component
@Slf4j
public class demo {
    
	
	
	@Autowired
	private OrderSequenceMasterService orderSequenceMasterService;
	
	@Autowired
	private OrderSequenceSalveService orderSequenceSalveService;
	
	
	@Autowired
	private UserMasterService userMasterService;
	
	@Autowired
	private UserSalveService userSalveService;
	
	// 读取主库 插入从库    
	//@Scheduled(cron = "*/5 * * * * ?")// 
	@Async
	public void demo1() {
		String table = null;
		String flag = "1";
		if("1".equals(flag)) {
			table ="user";
		}else {
			table = "user_01";
		}
		
		List<UserMasterEntity> getuser = userMasterService.getuser(table);
		System.out.println("获取主表数据:"+table+"的"+getuser.size());
		
		userSalveService.SaveUserMasterList(getuser,table);
		System.out.println("插入从表数据:"+table+"的111");  
		
	}
	
	
	// 读取从库 插入主库    
	//@Scheduled(cron = "0 * * * * ?")// 
	@Async
	public void demo2() {
		
	}
}
